A programming language compiler is a computer program that reads source files to produce a binary file. The source files describe the program using a computer language such as C, C++, COBOL and so on. The binary file produced by the compiler contains a series of binary machine instructions for some particular type of computer called the target computer.
The machine instructions generated by a compiler access the target computer's memory and registers using various kinds of pointers. The kinds of pointers that can be used vary between the different kinds of computer processors. The kind of pointer used for an operation can affect performance, where the pointer can be stored and where the pointer can point. By affecting where the pointer can point, pointer kinds affect variable allocation, which further affects program performance.
Prior art compilers have varying degrees of success at choosing pointer kinds. Variables are sometimes allocated based on types of pointers required, but changes to the use of variables caused by typical optimizations such as inlining and dead code elimination are generally ignored, so variable allocations do not take advantage of changes in pointer requirements. The lost potential advantages from inlining can be significant when pointers are passed as arguments or returned as results. Also, global variables are generally assumed to have worst-case pointer requirements. Prior art optimizations of pointer kinds tend to be handled as special cases. There is a need for a general mechanism for compilers to use for choosing the best pointer kinds that take advantage of other optimizations like inlining, which leads to the efficient allocation of both global and local variables.